﻿#ifndef SQLITEUTIL_H
#define SQLITEUTIL_H

#include "fileoperator.h"
#include "odbcutil.h"
#include <QObject>
#include <QList>
class SQLiteUtil : private OdbcUtil
{
public:
    SQLiteUtil(const QString &databaseName,QObject *parent = nullptr);
    ~SQLiteUtil();

    void initLoginDB();
    void initDataBaseDB();

    bool selectOneFriendIsExist();
    bool selectOneFriendIsExist(const QString& friend_id);
    QVariantMap selectOneFriendAlterTime(const QString& friend_id);
    QVariantMap selectOneFriendUsername(const QString &friend_id);
    QVariantMap selectOneFriendInfo(const QString &friend_id);
    QList<QVariantMap> selectAllFriendInfoList();
    QList<QVariantMap> selectAllFriendFUsername();
    bool updateFriendBind(QVariantMap& map, const QString& friend_id);
    bool insertFriend(QVariantMap &map);

    QList<QVariantMap> selectAllSessionNewInfo();
    QList<QVariantMap> selectAllSessionMsg(const QString &email);
    bool insertSession(QVariantMap& map);

    QVariantMap selectOneSelfInfo(const QString &msgId);
    QVariantMap selectOneMessageIsSend(const QString &msgId);
    QVariantMap selectOneMessageContent(const QString &msgId);
    QVariantMap selectOneMessageRecentContent(const QString &email);
    QVariantMap selectOneMessageType(const QString &msgId);
    QVariantMap selectOneMessageRecentCreateTime();
    bool updateMessage(QVariantMap &map,const QString &msgId);
    bool insertMessage(QVariantMap& map);

    QList<QVariantMap> selectAllAccoutDown();
    bool selectOneLoginIsExist(const QString &email);
    QVariantMap selectOneLoginRecentInfo();
    QVariantMap selectOneLoginAlterTime(const QString &email);
    QVariantMap selectOneLoginUserName(const QString &email);
    QVariantMap selectOneLoginUserInfo(const QString &email);
    QVariantMap selectOneLoginInfo(const QString &email);
    bool updateLoginBind(QVariantMap &map,const QString &email);
    bool insertLogin(QVariantMap &map);

    bool selectOneApplicationIsExist(const QString& friend_id);
    QVariantMap selectOneApplication(const QString &email);
    QString selectOneApplicationBuildTime(const QString& email);
    QString selectOneApplicationContent(const QString& email);
    bool updateApplication(QVariantMap &map,const QString friend_id);
    bool insertApplication(QVariantMap &map);
};

#endif // SQLITEUTIL_H
